//
//  WWTodayWeatherInfoCollectionViewCell.m
//  WhatWeather
//
//  Created by byn on 16/3/19.
//  Copyright © 2016年 byn. All rights reserved.
//

#import "WWTodayWeatherInfoCollectionViewCell.h"
#import "WWAqiWeatherInfoCollectionViewCell.h"
#import "UIImage+Extend.h"

@interface WWTodayWeatherInfoCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *windInfoLabel;

@property (weak, nonatomic) IBOutlet UILabel *tempretureLabel;
@property (weak, nonatomic) IBOutlet UIImageView *weatherImageView;
@property (weak, nonatomic) IBOutlet UIButton *showDailyForecastInfoButton;
@property (nonatomic ,strong) WWWeatherInfo *weatherInfo;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@end

@implementation WWTodayWeatherInfoCollectionViewCell

- (void)awakeFromNib {
    
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        [_collectionView registerNib:[UINib nibWithNibName:@"AqiWeatherInfo" bundle:nil] forCellWithReuseIdentifier:@"aqiWeatherInfo"];
        [_collectionView reloadData];
}

- (void)configureCell : (WWWeatherInfo *)weatherInfo {
    
    _weatherInfo = weatherInfo;
    
    _tempretureLabel.text = weatherInfo.nowTmp;
    _windInfoLabel.text = [NSString stringWithFormat:@"%@ %@",weatherInfo.nowWindDir,weatherInfo.nowWindSc];
    UIImage *img = [UIImage imageNamed:weatherInfo.nowWeatherCode];
    [_weatherImageView setImage:[img imageWithTintColor:[UIColor whiteColor]]];
    [_collectionView reloadData];
}

- (IBAction)showDailycastInfo:(id)sender {
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 7;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    return CGSizeMake(_collectionView.frame.size.width/2 -30, 80);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    WWAqiWeatherInfoCollectionViewCell *cell = (WWAqiWeatherInfoCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"aqiWeatherInfo" forIndexPath:indexPath];
    [cell configureCell:indexPath weatherInfo:_weatherInfo];
    return cell;
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 0.0;
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 0.0;
}

@end













































